/**
 * 
 */
package com.bemol.kernel.plugin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.jar.JarFile;

import com.bemol.kernel.repository.PersistenceObject;


/**
 * @author samuelgmartinez
 *
 */
public class PluginConfiguration {

	private List<Class<? extends PersistenceObject>> persistenceClasses;
	
	private String name;
	private String description;
	private String version;
	
	private JarFile jarFile;

	private Map<String, String> parameters;
	
	private Boolean frozen;
	
	public PluginConfiguration()  {
		parameters = new HashMap<String, String>();
	}
	
	public List<Class<? extends PersistenceObject>> getPersistenceClasses() {
		return persistenceClasses;
	}
	public void setPersistenceClasses(
			List<Class<? extends PersistenceObject>> persistenceClasses) {
		this.persistenceClasses = persistenceClasses;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.checkIsFrozen();
		this.name = name;
	}

	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.checkIsFrozen();
		this.description = description;
	}

	public Map<String, String> getParameters() {
		return parameters;
	}

	public void setParameters(Map<String, String> parameters) {
		this.checkIsFrozen();
		this.parameters = parameters;
	}

	
	public String getVersion() {
		return version;
	}
	public void setVersion(String version) {
		this.checkIsFrozen();
		this.version = version;
	}

	public JarFile getJarFile() {
		return jarFile;
	}
	public void setJarFile(JarFile jarFile) {
		this.checkIsFrozen();
		this.jarFile = jarFile;
	}

	public void freeze() {
		this.frozen = true;
	}
	
	private void checkIsFrozen() {
		if(frozen)
			throw new IllegalStateException("Configuration can't be modified once it is frozen");
	}
	
}
